package fr.enseirbmatmeca.apms.spring.model.project;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import org.hibernate.annotations.GenericGenerator;

import fr.enseirbmatmeca.apms.spring.model.user.User;

@Entity
public class ProjectGroup {

	/**
	 * 
	 *This class represent a project group holding the tutors, reporters and students links
	 *It also contain all marks for a project group and report file links
	 *Finally a reference to project allow to map it 
	 * @author coudar
	 *
	 */
	private String id;
	private List<User> reporters; // can mark the group
	private List<User> students; // students who are part of the project group
    private Project project; // project concerned
    
    private List<GlobalMark> reportMarks; //here are all the mark from the different reporters, reporter unicity is done programmatically
    private List<GlobalMark> presentationMarks; //same as reportMarks but for presentations
    private List<PersonalMark> personalMarks; //be sure to check there is only one mark from one reporters or tutors for every students
    
    private UploadedFile report;
    
    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    @Column(name = "id_projectGroup", unique = true, nullable = false)
	public String getId() {
		return id;
	}
	@OneToMany(targetEntity=PersonalMark.class, fetch=FetchType.LAZY)
	public List<PersonalMark> getPersonalMarks() {
		return personalMarks;
	}
	@OneToMany(targetEntity=GlobalMark.class, fetch=FetchType.LAZY)
	public List<GlobalMark> getPresentationMarks() {
		return presentationMarks;
	}
	@ManyToOne(targetEntity=Project.class, fetch=FetchType.LAZY)
	public Project getProject() {
		return project;
	}
	
	@ManyToOne(targetEntity=UploadedFile.class, fetch=FetchType.LAZY)
	public UploadedFile getReport() {
		return report;
	}
	@ManyToMany(targetEntity=User.class, fetch=FetchType.LAZY)
	 @JoinTable(name="reportersTable")
	public List<User> getReporters() {
		return reporters;
	}
	@OneToMany(targetEntity=GlobalMark.class, fetch=FetchType.LAZY)
	public List<GlobalMark> getReportMarks() {
		return reportMarks;
	}
	@ManyToMany(targetEntity=User.class, fetch=FetchType.LAZY)
	 @JoinTable(name="studentsTable")
	public List<User> getStudents() {
		return students;
	}
	
	public void setId(String id) {
		this.id = id;
	}
	
	public void setPersonalMarks(List<PersonalMark> personalMarks) {
		this.personalMarks = personalMarks;
	}
	public void setPresentationMarks(List<GlobalMark> presentationMarks) {
		this.presentationMarks = presentationMarks;
	}
	public void setProject(Project project) {
		this.project = project;
	}
	public void setReport(UploadedFile report) {
		this.report = report;
	}
	public void setReporters(List<User> reporters) {
		this.reporters = reporters;
	}
	public void setReportMarks(List<GlobalMark> reportMarks) {
		this.reportMarks = reportMarks;
	}
	public void setStudents(List<User> students) {
		this.students = students;
	}
    
}
